package com.ugoodtech.mdcc.client.controller;

import com.mysema.query.BooleanBuilder;
import com.ugoodtech.mdcc.client.controller.RequestObject.ServiceReportObject;
import com.ugoodtech.mdcc.client.controller.RequestObject.ServiceReportObjectUnFinshed;
import com.ugoodtech.mdcc.client.dto.JsonResponse;
import com.ugoodtech.mdcc.client.service.AliSmsProvider;
import com.ugoodtech.mdcc.client.service.StationServiceReportService;
import com.ugoodtech.mdcc.client.service.UserLogService;
import com.ugoodtech.mdcc.core.Constants;
import com.ugoodtech.mdcc.core.LogConstants;
import com.ugoodtech.mdcc.core.domain.*;
import com.ugoodtech.mdcc.core.repository.*;
import com.ugoodtech.mdcc.core.service.WechatService;
import com.ugoodtech.mdcc.core.utils.AnswerOtherUtil;
import com.ugoodtech.mdcc.core.utils.ArrayStringUtil;
import com.ugoodtech.mdcc.core.utils.DateUtil;
import com.ugoodtech.mdcc.core.utils.ValidateUtil;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.security.Principal;
import java.text.SimpleDateFormat;
import java.util.*;


@Api(description = "维修站服务常规报告相关接口")
@RestController
@RequestMapping("/stationServiceReportV")
public class StationServiceReportControllerV {

    @Autowired
    private StationRegularServiceReportRepository stationRegularServiceReportRepository;

    @Autowired
    private StationRegularServiceReportUnFinshedRepository stationRegularServiceReportUnFinshedRepository;

    @Autowired
    private StationReportRepository stationReportRepository;

    @Autowired
    private StationReportUnFinshedRepository stationReportUnFinshedRepository;

    @Autowired
    private StationServiceReportService stationServiceReportService;

    @Autowired
    private UserRepository userRepository;

    @Autowired
    private ModuleAuthorityRepository moduleAuthorityRepository;

    @Autowired
    private StationRepository stationRepository;

    @Autowired
    private CustomerRegularReportRepository customerRegularReportRepository;

    @Autowired
    private AliSmsProvider aliSmsProvider;

    @Autowired
    private UserProfileRepository userProfileRepository;

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Autowired
    private QuestionAnswerOptionRepository questionAnswerOptionRepository;

    @Autowired
    private DepartmentRepository departmentRepository;

    @Autowired
    private UserLogService userLogService;

    @Autowired
    private QuestionRepository questionRepository;

    @Autowired
    private ServiceReportRecorderRepository serviceReportRecorderRepository;

    @Autowired
    private ServiceReportHistoricalRecorderRepository serviceReportHistoricalRecorderRepository;

    @Autowired
    private WechatService wechatService;

    @Autowired
    private StationColorReportRepository stationColorReportRepository;


    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.DEFAULT_DATE_FORMAT);

    private static final Logger logger = LoggerFactory.getLogger(StationServiceReportControllerV.class);

    @ApiOperation("通过ID获取已经提交的报告-改")
    @RequestMapping(value = "getCompleteReport", method = RequestMethod.POST)
    public JsonResponse getCompleteReport(@ApiIgnore Principal principal,
                                          @ApiParam("报告ID") @RequestParam(value = "reportId") Long reportId) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        return stationServiceReportService.getCompleteReport(reportId);
    }

    @ApiOperation("通过ID获取暂时存储的报告-改")
    @RequestMapping(value = "getUnFinshedReport", method = RequestMethod.POST)
    public JsonResponse getUnFinshedReport(@ApiIgnore Principal principal,
                                           @ApiParam("报告ID") @RequestParam(value = "reportId") Long reportId) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        return stationServiceReportService.getUnFinshedReport(reportId);
    }

    @ApiOperation("创建常规服务报告-改")
    @RequestMapping(value = "createReport", method = RequestMethod.POST)
    public JsonResponse createReport(@ApiIgnore Principal principal,
                                     @RequestBody ServiceReportObject serviceReportObject,
                                     @ApiParam("服务项目多选") @RequestParam(value = "answerOther") String answerOther,
                                     @ApiParam("维修站ID") @RequestParam(value = "stationId") Long stationId,
                                     @ApiParam("报告状态") @RequestParam(value = "reportType") String reportType,
                                     @ApiParam("服务开始时间") @RequestParam(value = "startServiceTime") Long startServiceTime,
                                     @ApiParam("服务结束时间") @RequestParam(value = "endServiceTime") Long endServiceTime,
                                     @ApiParam("指定的部门负责人") @RequestParam(value = "deparmentIds", required = false) String deparmentIds,
                                     @ApiParam("暂存的报告ID") @RequestParam(value = "saveReportId", required = false) Long saveReportId,
                                     @ApiParam("提交者的身份") @RequestParam(value = "userType", required = false) Integer userType,
                                     @ApiParam("在计划中提交的报告ID") @RequestParam(value = "id", required = false) Long id) {
        logger.info("***************************************************************");
        logger.info("<<<<<<<<<<<<<<<<<<创建常规服务报告>>>>>>>>>>>>>>>>>");
        logger.info("<<<<<<<<<<<<<<<<<<维修站ID为：" + stationId + ">>>>>>>>>>>>>>>>>");
        logger.info("<<<<<<<<<<<<<<<<<<暂存报告ID为" + saveReportId + ">>>>>>>>>>>>>>>>>");
        logger.info("<<<<<<<<<<<<<<<<<<指定的部门：" + deparmentIds + ">>>>>>>>>>>>>>>>>");
        logger.info("<<<<<<<<<<<<<<<<<<在计划中提交的报告ID：" + id + ">>>>>>>>>>>>>>>>>");
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到当前登录用户");
        }
        if (StringUtils.isNotEmpty(deparmentIds)) {
            String[] departmentIds = deparmentIds.split(",");
            for (String did : departmentIds) {
                if (StringUtils.isNotEmpty(did)) {
                    try {
                        Department department = departmentRepository.findOne(Long.valueOf(did));
                        if (department == null) {
                            return JsonResponse.errorResponseWithError("抱歉", "请选择正确的部门");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        return JsonResponse.errorResponseWithError("抱歉", "请选择正确的部门");
                    }
                }
            }
        }
        try {
            List<StationRegularServiceReport> regularServiceReports = serviceReportObject.getStationRegularServiceReportList();
            logger.info("<<<<<<<<<<<<<<<<<<提交题目数量为：" + regularServiceReports.size() + ">>>>>>>>>>>>>>>>>");
            JsonResponse jsonResponse = toComplete(clientUser, regularServiceReports, stationId, reportType, deparmentIds, saveReportId, startServiceTime, endServiceTime, id, answerOther,userType);
//                if(jsonResponse.isSuccess()){
//                    //     删除报告===================================
//                    userLogService.addUserLog(clientUser, stationId,LogConstants.operate_type_add,LogConstants.business_type_audit_report,null,null);
//
//                }
            return jsonResponse;
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResponse.errorResponseWithError("抱歉", "创建失败");
        }
    }

    private JsonResponse toComplete(User user, List<StationRegularServiceReport> regularServiceReports,
                                    Long stationId, String reportType, String deparmentIds, Long saveReportId, Long startServiceTime, Long endServiceTime, Long id, String answerOther,Integer userType) {
        String telephone = "";
        String technologyUser = "";
        UserProfile userProfile = userProfileRepository.findByUserId(user.getId());
        technologyUser = userProfile.getRealName() == null ? "服务人员" : userProfile.getRealName();
        logger.info("外勤人员的ID为：" + user.getId());
        if (userProfile == null) {
            return JsonResponse.errorResponseWithError("抱歉", "未找到当前登录用户");
        }
        Station station = stationRepository.findOne(stationId);
        if (station == null) {
            return JsonResponse.errorResponseWithError("抱歉", "维修站未找到");
        }
        if (StringUtils.isEmpty(reportType)) {
            return JsonResponse.errorResponseWithError("抱歉", "报告状态错误");
        }
//==============计划报告提交======================
        if (id != null && id != 0) {
            int planId = 0;
            logger.info("<<<<<<<<<<<<<<<<<<计划报告>>>>>>>>>>>>>>>>>");
            StationReport stationReport = stationReportRepository.findOne(id);
            if (stationReport == null) {
                return toComplete(user, regularServiceReports, stationId, reportType, deparmentIds, saveReportId, startServiceTime, endServiceTime, null, answerOther,userType);
            }
            Date date = new Date();
            stationReport.setUpdateTime(date);
            stationReport.setUpdateTimeStr(simpleDateFormat.format(date));
            stationReport.setDeparmentIds(deparmentIds);
            stationReport.setStartServiceTime(new Date(startServiceTime));
            stationReport.setEndServiceTime(new Date(endServiceTime));
            stationReport.setReportType(reportType);
            stationReport.setCategory(Constants.SERVICE_REPORT);
            stationReport.setUserType(userType);
            stationReport.setUser(user);
            if (StringUtils.isNotEmpty(answerOther)) {
                logger.info("<<<<<<<<<<<<<<<<<<有多选的常规服务项目:" + answerOther + ">>>>>>>>>>>>>>>>>");
                stationReport.setAnswerOther(answerOther);
            }
            if (StringUtils.isNotEmpty(deparmentIds)) {
                stationReport.setDeparmentIds(deparmentIds);
                stationReport.setSpecifiedType(Constants.MANAGE_DEPARTMENT_UNREAD);
                stationReport.setIsfollowed(true);
            } else {
                stationReport.setDeparmentIds(null);
                stationReport.setSpecifiedType(null);
                stationReport.setIsfollowed(false);
            }
            stationReportRepository.save(stationReport);

            QStationRegularServiceReport qStationRegularServiceReport = QStationRegularServiceReport.stationRegularServiceReport;
            BooleanBuilder builder = new BooleanBuilder();
            builder.and(qStationRegularServiceReport.deleted.eq(false));
            builder.and(qStationRegularServiceReport.enabled.eq(true));
            builder.and(qStationRegularServiceReport.stationReport.category.eq(Constants.SERVICE_REPORT));
            builder.and(qStationRegularServiceReport.stationReport.reportType.eq(Constants.REPORT_TYPE_COMPLETE));
            builder.and(qStationRegularServiceReport.stationReport.id.eq(id));
            List<StationRegularServiceReport> stationRegularServiceReports = (List<StationRegularServiceReport>) stationRegularServiceReportRepository.findAll(builder);
            if (stationRegularServiceReports == null || stationRegularServiceReports.size() <= 0) {
                logger.info("<<<<<<<<<<<<<<<<<<是提交完之后-再点暂存-再点提交，因此没有原先的报告答案>>>>>>>>>>>>>>>>>");
                return toComplete(user, regularServiceReports, stationId, reportType, deparmentIds, saveReportId, startServiceTime, endServiceTime, null, answerOther,userType);
            }
            String realName = "";
            String posstion = "";
            for (StationRegularServiceReport regularServiceReport : regularServiceReports) {
                if (regularServiceReport.getQuestionId() == 178) {
                    realName = regularServiceReport.getAnswerOther();
                }
                if (regularServiceReport.getQuestionId() == 179) {
                    posstion = regularServiceReport.getAnswerOther();
                }
            }
            User concatUser = null;
            String serviceTypeId = "";
            logger.info("<<<<<<<<<<<<<<<<<<是提交完之后-再点暂存-再点提交，因此没有原先的报告答案>>>>>>>>>>>>>>>>>");
            String desc = "";
            for (StationRegularServiceReport complete : regularServiceReports) {
                if (complete.getQuestionId().equals(156L)) {
                    logger.info("<<<<<<<<<<<<<<<<<<判断是否是计划的报告>>>>>>>>>>>>>>>>>");
                    planId = Integer.valueOf(complete.getAnswerId());
                }
                if (complete.getQuestionId() == 155L) {
                    logger.info("<<<<<<<<<<<<<<<<<<此报告技术服务目标为:" + complete.getAnswerId() + ">>>>>>>>>>>>>>>>>");
                    stationReport.setServiceTypAnswerIds(complete.getAnswerId());
                    serviceTypeId = complete.getAnswerId();
                    stationReportRepository.save(stationReport);
                }

//                todo==============

                UserProfile stationUserProfile;
                if (complete.getQuestionId() == 180L) {
                    telephone = complete.getAnswerOther();
                    logger.info("<<<<<<<<<<<<<<<<<<客户的手机号为：" + telephone + ">>>>>>>>>>>>>>>>>");
                    User stationUser = userRepository.findByUsername(complete.getAnswerOther());
                    if (stationUser != null) {
                        if (stationUser.getUserFlag() != 1){
                            stationUser.setUserFlag(2);
                        }
                        concatUser = stationUser;
                        //TODO 现在客户信息和站点是一对一的关系，以后可能改成一对多
                        if (stationUser.getStationId() != null && stationUser.getStationId() != 0) {
                            logger.info("<<<<<<<<<<<<<<<<<<客户所在维修站ID为：" + stationUser.getStationId() + ">>>>>>>>>>>>>>>>>");
                            if (!stationUser.getStationId().equals(stationId)) {
                                return JsonResponse.errorResponseWithError("抱歉", "该人员属于其它维修站");
                            }
                        }
                        if (stationUser.getUserType().equals(UserType.insiders)){
                            return JsonResponse.errorResponseWithError("抱歉", "该人员是内部人员无法作为维修站联系人");
                        }
                        userRepository.save(stationUser);
                    }
                    else{
                        logger.info("<<<<<<<<<<<<<<<<<<开始新建客户账号>>>>>>>>>>>>>>>>>");
                        concatUser = new User();
                        concatUser.setUsername(complete.getAnswerOther());
                        concatUser.setPassword(passwordEncoder.encode(Constants.INIT_PASSWORD));
                        concatUser.setUserType(UserType.customer);
                        concatUser.setStationId(stationId);
                        concatUser.setUserFlag(1);
                        userRepository.save(concatUser);
                        stationUserProfile = new UserProfile();
                        stationUserProfile.setRealName(realName);
                        stationUserProfile.setPosition(posstion);
                        stationUserProfile.setTelephone(telephone);
                        stationUserProfile.setMobilePhone(telephone);
                        stationUserProfile.setUser(concatUser);
                        userProfileRepository.save(stationUserProfile);
                        logger.info("<<<<<<<<<<<<<<<<<<新建完毕>>>>>>>>>>>>>>>>>");
                    }
                }
                for (StationRegularServiceReport unfinshed : stationRegularServiceReports) {
                    Question question = questionRepository.findOne(complete.getQuestionId());
                    if (complete.getQuestionId().equals(unfinshed.getQuestionId())) {
                        //                        如果题目的答案有修改的话记录日志===============================================
                        if (!unfinshed.getAnswerOther().equals(complete.getAnswerOther()) ||
                                !unfinshed.getAnswerId().equals(complete.getAnswerId())) {
                            desc += question.getSubject() + ":";
                            desc += getAnswerString(unfinshed.getAnswerId()) + filterAnswerOther(unfinshed.getAnswerOther()) + "-->>" + getAnswerString(complete.getAnswerId()) + filterAnswerOther(complete.getAnswerOther()) + ",";
                        }
//                        =========================================================================
                        unfinshed.setAnswerOther(complete.getAnswerOther());
                        unfinshed.setAnswerId(complete.getAnswerId());
                        unfinshed.setAnswerPhoto(complete.getAnswerPhoto());
                        unfinshed.setStationReport(stationReport);
                        stationRegularServiceReportRepository.save(unfinshed);
                        continue;
                    }
                }
            }
            Map<String, Object> data = new HashMap<>();
            data.put("str", desc);
            ServiceReportHistoricalRecorder serviceReportHistoricalRecorder = new ServiceReportHistoricalRecorder();
            serviceReportHistoricalRecorder.setUser(user);
            serviceReportHistoricalRecorder.setNote("修改了计划报告");
            serviceReportHistoricalRecorder.setType("修改为提交报告");
            serviceReportHistoricalRecorder.setStationReport(stationReport);
            serviceReportHistoricalRecorderRepository.save(serviceReportHistoricalRecorder);
//354是计划报告==========================================
            if (planId != 354) {
                CustomerRegularReport customerRegularReport = new CustomerRegularReport();
                customerRegularReport.setContactUser(concatUser);
                customerRegularReport.setRegularReport(stationReport);
                customerRegularReport.setEnabled(false);
                customerRegularReportRepository.save(customerRegularReport);
                StringBuffer stringBuffer = new StringBuffer("");
                if (StringUtils.isNotEmpty(serviceTypeId)) {
                    String[] str = serviceTypeId.split(",");
                    for (String s : str) {
                        QuestionAnswerOption answerOption = questionAnswerOptionRepository.findOne(Long.valueOf(s));
                        if (answerOption.getId().equals(191L)) {
                            stringBuffer = new StringBuffer("漆星服务");
                            break;
                        }
                        stringBuffer.append(answerOption.getName());
                    }
                }
                String serviceStr = stringBuffer.toString();
                if (!serviceStr.equals("漆星服务")) {
                    serviceStr = serviceStr.substring(0, serviceStr.length() - 1);
                }
                try {
//                    aliSmsProvider.sendCustomerMsg(telephone, technologyUser, simpleDateFormat.format(date),
//                            station.getName(), serviceStr);
                    logger.info("<<<<<<<<<<<<<<<<<<计划报告提交成功>>>>>>>>>>>>>>>>>");
                    userLogService.addUserLog(user, station.getStationNum(), saveReportId, Constants.TECHCOLOR_REPORT, LogConstants.operate_type_plan_submit, LogConstants.business_type_regular_report_plan, null, data);
                    return JsonResponse.successResponseWithData("已发送短信通知客户填写满意度报告");
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.info("<<<<<<<<<<<<<<<<<<发送失败>>>>>>>>>>>>>>>>>!");
                    e.printStackTrace();
                    return JsonResponse.errorResponseWithError("fail", "发送通知失败");
                }
            } else {
                if (null != data.get("str")) {
                    userLogService.addUserLog(user, station.getStationNum(), saveReportId, Constants.TECHCOLOR_REPORT, LogConstants.operate_type_edit, LogConstants.business_type_regular_report_plan, null, data);
                }
                return JsonResponse.successResponse();
            }
        }
        String realName = "";
        String posstion = "";
        for (StationRegularServiceReport regularServiceReport : regularServiceReports) {
            if (regularServiceReport.getQuestionId() == 178) {
                realName = regularServiceReport.getAnswerOther();
            }
            if (regularServiceReport.getQuestionId() == 179) {
                posstion = regularServiceReport.getAnswerOther();
            }
        }
        User concatUser = null;

        logger.info("<<<<<<<<<<<<<<<<<<判断常规报告中的联系人是否已经存在>>>>>>>>>>>>>>>>>");
        Station addStation = stationRepository.findOne(stationId);
        for (StationRegularServiceReport regularServiceReport : regularServiceReports) {
            if (null == regularServiceReport.getQuestionId()) {
                continue;
            }
            UserProfile stationUserProfile = null;
            if (regularServiceReport.getQuestionId() == 180L) {
                telephone = regularServiceReport.getAnswerOther();
                logger.info("<<<<<<<<<<<<<<<<<<客户的手机号为：" + telephone + ">>>>>>>>>>>>>>>>>");
                User stationUser = userRepository.findByUsername(regularServiceReport.getAnswerOther());
                concatUser = stationUser;
                if (stationUser != null) {
                    if (stationUser.getUserType().equals(UserType.insiders)){
                        return JsonResponse.errorResponseWithError("抱歉", "该人员是内部人员无法作为维修站联系人");
                    }
                    stationUserProfile = userProfileRepository.findByUserId(stationUser.getId());
                    if (stationUserProfile == null) {
                        return JsonResponse.errorResponseWithError("抱歉", "未找到此联系人具体信息");
                    }

                    if (stationUserProfile.getStationList() != null && stationUserProfile.getStationList().size() > 0) {
                        if (!stationUserProfile.getStationList().contains(addStation)) {
                            List<Station> stationList = stationUserProfile.getStationList();
                            stationList.add(addStation);
                            stationUserProfile.setStationList(stationList);
                            stationUserProfile.setAddUser(userProfile);
                            userProfileRepository.save(stationUserProfile);
                        }
                    } else {
                        List<Station> stationList = new ArrayList<>();
                        stationList.add(addStation);
                        stationUserProfile.setStationList(stationList);
                        stationUserProfile.setAddUser(userProfile);
                        userProfileRepository.save(stationUserProfile);
                        break;
                    }

//                    if (stationUser.getStationId() != null && stationUser.getStationId() != 0) {
//                        logger.info("<<<<<<<<<<<<<<<<<<客户所在维修站ID为：" + stationUser.getStationId() + ">>>>>>>>>>>>>>>>>");
//                        if (!stationUser.getStationId().equals(stationId)) {
//                            return JsonResponse.errorResponseWithError("抱歉", "该人员属于其它维修站");
//                        }
//                        if (stationUserProfile == null) {
//                            return JsonResponse.errorResponseWithError("抱歉", "未找到此联系人具体信息");
//                        } else {
//                            concatUser = stationUser;
//                        }
//                    } else {
//                        String usertype = "内部人员";
//                        if (user.getUserType().equals(UserType.dealers)) {
//                            usertype = "经销商";
//                        }
//                        return JsonResponse.errorResponseWithError("抱歉", "该人员是" + usertype + "无法作为维修站联系人");
//                    }

                }
                if (stationUser == null) {
                    logger.info("<<<<<<<<<<<<<<<<<<开始新建客户账号>>>>>>>>>>>>>>>>>");
                    concatUser = new User();
                    concatUser.setUsername(regularServiceReport.getAnswerOther());
                    concatUser.setPassword(passwordEncoder.encode(Constants.INIT_PASSWORD));
                    concatUser.setUserType(UserType.customer);
                    concatUser.setStationId(stationId);
                    userRepository.save(concatUser);
                    stationUserProfile = new UserProfile();
                    stationUserProfile.setRealName(realName);
                    stationUserProfile.setPosition(posstion);
                    stationUserProfile.setTelephone(telephone);
                    stationUserProfile.setAddUser(userProfile);
                    List<Station> stationList = new ArrayList<>();
                    stationList.add(addStation);
                    stationUserProfile.setStationList(stationList);
                    stationUserProfile.setAddUser(userProfile);
                    stationUserProfile.setUser(concatUser);
                    userProfileRepository.save(stationUserProfile);
                    logger.info("<<<<<<<<<<<<<<<<<<新建完毕>>>>>>>>>>>>>>>>>");
                }
            } else {
                continue;
            }
        }
        if (saveReportId != null && saveReportId != 0) {
            logger.info("<<<<<<<<<<<<<<<<<<有暂存的报告>>>>>>>>>>>>>>>>>");
            QStationReportTemp qStationReportTemp = QStationReportTemp.stationReportTemp;
            BooleanBuilder builder = new BooleanBuilder();
            builder.and(qStationReportTemp.deleted.eq(false));
            builder.and(qStationReportTemp.enabled.eq(true));
            builder.and(qStationReportTemp.reportCategory.eq(Constants.SERVICE_REPORT));
            builder.and(qStationReportTemp.id.eq(saveReportId));
            StationReportTemp stationReportUnFinshed = stationReportUnFinshedRepository.findOne(builder);
            if (stationReportUnFinshed == null) {
                return JsonResponse.errorResponseWithError("抱歉", "暂存的报告未找到");
            }
            logger.info("<<<<<<<<<<<<<<<<<<逻辑删除暂存的报告>>>>>>>>>>>>>>>>>");
            stationReportUnFinshed.setDeleted(true);
            stationReportUnFinshed.setEnabled(false);
            stationReportUnFinshedRepository.save(stationReportUnFinshed);
            QStationRegularServiceReportUnFinshed qStationRegularServiceReportUnFinshed = QStationRegularServiceReportUnFinshed.stationRegularServiceReportUnFinshed;
            builder = new BooleanBuilder();
            builder.and(qStationRegularServiceReportUnFinshed.deleted.eq(false));
            builder.and(qStationRegularServiceReportUnFinshed.enabled.eq(true));
            builder.and(qStationRegularServiceReportUnFinshed.stationReportTemp.id.eq(saveReportId));
            List<StationRegularServiceReportUnFinshed> unFinshedList = (List<StationRegularServiceReportUnFinshed>) stationRegularServiceReportUnFinshedRepository.findAll(builder);
            if (unFinshedList.size() <= 0) {
                return JsonResponse.errorResponseWithError("抱歉", "暂存的报告答案结果未找到");
            }
            logger.info("<<<<<<<<<<<<<<<<<<逻辑删除暂存报告答案>>>>>>>>>>>>>>>>>");
            for (StationRegularServiceReportUnFinshed unFinshed : unFinshedList) {
                unFinshed.setDeleted(true);
                unFinshed.setEnabled(false);
                stationRegularServiceReportUnFinshedRepository.save(unFinshed);
            }
        }
        logger.info("<<<<<<<<<<<<<<<<<<新建常规报告>>>>>>>>>>>>>>>>>");
        StationReport stationReport = new StationReport();
        stationReport.setStation(station);
        stationReport.setUser(user);
        stationReport.setReportType(reportType);
        stationReport.setCategory(Constants.SERVICE_REPORT);
        stationReport.setStartServiceTime(new Date(startServiceTime));
        stationReport.setEndServiceTime(new Date(endServiceTime));
        stationReport.setUserType(userType);
        if (StringUtils.isNotEmpty(answerOther)) {
            logger.info("<<<<<<<<<<<<<<<<<<有多选的常规服务项目:" + answerOther + ">>>>>>>>>>>>>>>>>");
            stationReport.setAnswerOther(answerOther);
        }
        if (StringUtils.isNotEmpty(deparmentIds)) {
            logger.info("<<<<<<<<<<<<<<<<<<有跟进的部门:" + deparmentIds + ">>>>>>>>>>>>>>>>>");
            stationReport.setDeparmentIds(deparmentIds);
            stationReport.setSpecifiedType(Constants.MANAGE_DEPARTMENT_UNREAD);
            stationReport.setIsfollowed(true);
        }
        stationReportRepository.save(stationReport);
        user.setServiceNum(user.getServiceNum()+1);
        userRepository.save(user);
        int planId = 0;
        String serviceTypeId = "";
        for (StationRegularServiceReport regularServiceReport : regularServiceReports) {
            regularServiceReport.setStationReport(stationReport);
            if (regularServiceReport == null || regularServiceReport.getQuestionId() == null) {
                continue;
            }
            if (regularServiceReport.getAnswerId().equals("182")) {
                stationReport.setDeparmentIds(deparmentIds);
                stationReport.setSpecifiedType(Constants.MANAGE_DEPARTMENT_UNREAD);
                stationReport.setIsfollowed(true);
                stationReport.setImprovementTime(1L);
                stationReportRepository.save(stationReport);
            }
            if (regularServiceReport.getQuestionId() == 155L) {
                stationReport.setServiceTypAnswerIds(regularServiceReport.getAnswerId());
                serviceTypeId = regularServiceReport.getAnswerId();
                stationReportRepository.save(stationReport);
            }
            if (regularServiceReport.getQuestionId() == 180L) {
                stationReport.setContactUser(regularServiceReport.getAnswerOther());
                stationReportRepository.save(stationReport);
            }
            if (regularServiceReport.getQuestionId().equals(156L)) {
                logger.info("<<<<<<<<<<<<<<<<<<判断是否是计划的报告>>>>>>>>>>>>>>>>>");
                // planId保存该用户是否是计划的报告
                planId = Integer.valueOf(regularServiceReport.getAnswerId());
            }
            stationRegularServiceReportRepository.save(regularServiceReport);
        }
        //todo 短信推送消息 提示让客户填写满意度报告
        // 判断：如果是服务结果是计划中就 无需发送短信通知用户填写报告
        logger.info("<<<<<<<<<<<<<<<<<<planId：" + planId + ">>>>>>>>>>>>>>>>>");
        if (planId != 354) {
            // 生成满意度报告
            CustomerRegularReport customerRegularReport = new CustomerRegularReport();
            customerRegularReport.setContactUser(concatUser);
            customerRegularReport.setRegularReport(stationReport);
            customerRegularReport.setEnabled(false);
            customerRegularReportRepository.save(customerRegularReport);
            logger.info("<<<<<<<<<<<<<<<<<<不是计划的报告>>>>>>>>>>>>>>>>>");
            logger.info("<<<<<<<<<<<<<<<<<<给客户发送短信，手机号为：" + telephone + ">>>>>>>>>>>>>>>>>");
            User msgUser = userRepository.findByUsername(telephone);
            if (msgUser == null) {
                return JsonResponse.errorResponseWithError("抱歉", "手机号未注册过");
            }
            if (msgUser.isEnabled() == false) {
                return JsonResponse.errorResponseWithError("抱歉", "此用户已被禁用");
            }
            StringBuffer stringBuffer = new StringBuffer("");
            if (StringUtils.isNotEmpty(serviceTypeId)) {
                String[] str = serviceTypeId.split(",");
                for (String s : str) {
                    QuestionAnswerOption answerOption = questionAnswerOptionRepository.findOne(Long.valueOf(s));
                    if (answerOption.getId().equals(191L)) {
                        stringBuffer = new StringBuffer("漆星服务");
                        break;
                    }
                    stringBuffer.append(answerOption.getName() + ",");
                }
            }
//            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(Constants.DATE_FORMAT);
            StationRegularServiceReport regularServiceReport = stationRegularServiceReportRepository.selectQuestionOther(stationReport.getId(), 177L);
            String dateTime = "";
            if (regularServiceReport != null && StringUtils.isNotEmpty(regularServiceReport.getAnswerOther())) {
                dateTime = regularServiceReport.getAnswerOther();
            }

            // 如果需要其他部门跟进 就记录到跟进进度中
            StringBuffer departmentBuffer = new StringBuffer("");
            if (StringUtils.isNotEmpty(deparmentIds)) {
                try {
                    String[] departmentIds = deparmentIds.split(",");
                    for (String did : departmentIds) {
                        if (StringUtils.isNotEmpty(did)) {
                            Department department = departmentRepository.findOne(Long.valueOf(did));
                            if (department != null && StringUtils.isNotEmpty(department.getTotalName())) {
                                departmentBuffer.append(department.getTotalName());
                            }
                        }
                    }
                    ServiceReportRecorder serviceReportRecorder = new ServiceReportRecorder();
                    regularServiceReport = stationRegularServiceReportRepository.selectQuestionOther(stationReport.getId(), 157L);
                    if (regularServiceReport != null && StringUtils.isNotEmpty(regularServiceReport.getAnswerOther())) {
                        serviceReportRecorder.setNote("服务人员自我评估：" + regularServiceReport.getAnswerOther());
                    } else {
                        serviceReportRecorder.setNote("");
                    }
                    UserProfile departmentProfile = userProfileRepository.findByUserId(user.getId());
                    serviceReportRecorder.setUser(user);
                    serviceReportRecorder.setType("需其他部门跟进");
                    serviceReportRecorder.setDepartment(departmentProfile.getDepartmentList().get(0));
                    serviceReportRecorder.setNeedFollowDepartment(departmentBuffer.toString());
                    serviceReportRecorder.setStationReport(stationReport);
                    serviceReportRecorderRepository.save(serviceReportRecorder);
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }

            ServiceReportHistoricalRecorder serviceReportHistoricalRecorder = new ServiceReportHistoricalRecorder();
            serviceReportHistoricalRecorder.setUser(user);
            serviceReportHistoricalRecorder.setNote("修改了计划报告");
            serviceReportHistoricalRecorder.setType("修改为提交报告");
            serviceReportHistoricalRecorder.setStationReport(stationReport);
            serviceReportHistoricalRecorderRepository.save(serviceReportHistoricalRecorder);

            try {
                StationReport colorReport = stationReportRepository.selectReport(station.getId());
                if (null != colorReport) {
                    logger.info("<<<<<<<<<<<<<<<<<<是目标用户，不发送短信通知客户填写满意度>>>>>>>>>>>>>>>>>!");
                    StationColorReport colorReport1 = stationColorReportRepository.selectReport(colorReport.getId(), 184L);
                    if (null != colorReport1 && colorReport1.getAnswerId().equals("360")) {
                        return JsonResponse.successResponseWithData("已发送短信通知客户填写满意度报告");
                    }
                }
                /**
                 * 发送给客户
                 */
//                logger.info("<<<<<<<<<<<<<<<<<<开始发送短信>>>>>>>>>>>>>>>>>");
                logger.info("发送的号码为：" + telephone);
                logger.info("外勤人员为：" + technologyUser);
                logger.info("维修站为：" + station.getName());
                logger.info("维修站iD为：" + station.getId());
                logger.info("服务目标为：" + stringBuffer.toString());
                String serviceStr = stringBuffer.toString();
                if (!serviceStr.equals("漆星服务")) {
                    serviceStr = serviceStr.substring(0, serviceStr.length() - 1);
                }
//                aliSmsProvider.sendCustomerMsg(telephone, technologyUser, dateTime,
//                        station.getName(), serviceStr);
                userLogService.addUserLog(user, station.getStationNum(), saveReportId, Constants.SERVICE_REPORT, LogConstants.operate_type_add, LogConstants.business_type_regular_report, null, null);
//                logger.info("<<<<<<<<<<<<<<<<<<短信发送成功>>>>>>>>>>>>>>>>>!");
//                logger.info("<<<<<<<<<<<<<<<<<<开始推送微信>>>>>>>>>>>>>>>>>");
                String firstData = "您好，在" + station.getName() + "进行的" + stringBuffer.toString() + "已完成";
//                wechatService.pushWechatMessage(msgUser, "Ujk2bjdBKx3vU1IjSH3OyD84rgF0Hz-oU2Ds564DW2I", Constants.WECHAT_PUSH_URL, firstData,
//                        "请登录漆星服务公众号对Ta的本次服务进行打分", technologyUser, stationReport.getUpdateTimeStr(), "", "", "");
                logger.info("<<<<<<<<<<<<<<<<<<推送微信成功>>>>>>>>>>>>>>>>>");

                //有需要部门跟进的常规报告
                if (StringUtils.isNotEmpty(deparmentIds)) {
                    /**
                     * 发送给有权限的人
                     */
                    ModuleAuthority m = moduleAuthorityRepository.findByName(Constants.SERVICE_REPORT_FOLLOW_UP);
                    QUser qUser = QUser.user;
                    BooleanBuilder userBuilder = new BooleanBuilder();
                    userBuilder.and(qUser.deleted.eq(false));
                    userBuilder.and(qUser.enabled.eq(true));
                    userBuilder.and(qUser.authorities.any().id.eq(m.getId()));
                    List<User> userList = (List<User>) userRepository.findAll(userBuilder);
//                    StringBuffer telephoneStr = new StringBuffer("");
                    Map<String, User> stringUserMap = new HashMap<>();
                    for (User u : userList) {
                        stringUserMap.put(u.getOpenId(), u);
//                        telephoneStr.append(u.getUsername() + ",");
                    }
                    logger.info("<<<<<<<<<<<<<<<<<<开始发送短信给Rebeca与Perry>>>>>>>>>>>>>>>>>");
//                    logger.info("发送的号码为：" + telephoneStr);
                    logger.info("外勤人员为：" + technologyUser);
                    logger.info("维修站为：" + station.getName());
                    logger.info("服务目标为：" + stringBuffer.toString());
//                    aliSmsProvider.sendSms_needDepartment(telephoneStr.toString(), technologyUser, station.getName(), serviceStr, departmentBuffer.toString());
                    String keyWord3 = "在" + station.getName() + "进行的" + stringBuffer.toString() + "技术服务,需要" + departmentBuffer.toString() + "跟进处理。";
                    firstData = "您好，有一份常规报告需要管理员审批。";
                    for (Map.Entry<String, User> userEntry : stringUserMap.entrySet()) {
                        wechatService.pushWechatMessage(userEntry.getValue(), "sPL21Oj3MEQjKjGS-GDHQFC_L5Ngiz4zLxsRcYEXAcc", Constants.WECHAT_PUSH_URL, firstData,
                                "请尽快查看和审批！", technologyUser, stationReport.getUpdateTimeStr(), keyWord3, "", "");
                    }
                }
            } catch (Exception e) {
                logger.info("<<<<<<<<<<<<<<<<<<发送失败>>>>>>>>>>>>>>>>>!");
                e.printStackTrace();
                return JsonResponse.errorResponseWithError("fail", "发送通知失败");
            }
        } else {
            ServiceReportHistoricalRecorder serviceReportHistoricalRecorder = new ServiceReportHistoricalRecorder();
            serviceReportHistoricalRecorder.setUser(user);
            serviceReportHistoricalRecorder.setNote("修改了计划报告");
            serviceReportHistoricalRecorder.setType("修改为提交报告");
            serviceReportHistoricalRecorder.setStationReport(stationReport);
            serviceReportHistoricalRecorderRepository.save(serviceReportHistoricalRecorder);
            userLogService.addUserLog(user, station.getStationNum(), saveReportId, Constants.SERVICE_REPORT, LogConstants.operate_type_add, LogConstants.business_type_regular_report_plan, null, null);
        }
        logger.info("<<<<<<<<<<<<<<<<<<已发送短信和微信通知客户填写满意度报告>>>>>>>>>>>>>>>>>!");
        return JsonResponse.successResponseWithData("已发送短信通知客户填写满意度报告");
    }

    @ApiOperation("暂时存储常规服务报告-改")
    @RequestMapping(value = "saveReport", method = RequestMethod.POST)
    public JsonResponse saveReport(@ApiIgnore Principal principal,
                                   @RequestBody ServiceReportObjectUnFinshed stationRegularServiceReportUnFinshedList,
                                   @ApiParam("多选的服务项目") @RequestParam(value = "answerOther") String answerOther,
                                   @ApiParam("维修站ID") @RequestParam(value = "stationId") Long stationId,
                                   @ApiParam("unfinished") @RequestParam(value = "reportType") String reportType,
                                   @ApiParam("指定的部门负责人") @RequestParam(value = "deparmentIds", required = false) String userIds,
                                   @ApiParam("暂存的报告ID") @RequestParam(value = "tempReportId", required = false) Long reportId,
                                   @ApiParam("服务开始时间") @RequestParam(value = "startServiceTime") Long startServiceTime,
                                   @ApiParam("服务结束时间") @RequestParam(value = "endServiceTime") Long endServiceTime,
                                   @ApiParam("当前暂存的章节ID") @RequestParam(value = "sectionId") Long sectionId,
                                   @ApiParam("提交者身份") @RequestParam(value = "userType") Integer userType,
                                   @ApiParam("锚点") @RequestParam(value = "anchor") String anchor,
                                   @ApiParam("计划报告的ID") @RequestParam(value = "serviceReportId", required = false) Long serviceReportId) {
        logger.info("***************************************************************");
        logger.info("<<<<<<<<<<<<<<<<<<创建常规服务报告>>>>>>>>>>>>>>>>>");
        logger.info("<<<<<<<<<<<<<<<<<<维修站ID为：" + stationId + ">>>>>>>>>>>>>>>>>");
        logger.info("<<<<<<<<<<<<<<<<<<暂存报告ID为" + reportId + ">>>>>>>>>>>>>>>>>");
        logger.info("<<<<<<<<<<<<<<<<<<指定的部门：" + userIds + ">>>>>>>>>>>>>>>>>");
        logger.info("<<<<<<<<<<<<<<<<<<在计划中提交的报告ID：" + serviceReportId + ">>>>>>>>>>>>>>>>>");
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        if (StringUtils.isNotEmpty(userIds)) {
            String[] departmentIds = userIds.split(",");
            for (String id : departmentIds) {
                if (StringUtils.isNotEmpty(id)) {
                    try {
                        Department department = departmentRepository.findOne(Long.valueOf(id));
                        if (department == null) {
                            return JsonResponse.errorResponseWithError("抱歉", "请选择正确的部门");
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        return JsonResponse.errorResponseWithError("抱歉", "请选择正确的部门");
                    }
                }
            }
        }
        try {
            List<StationRegularServiceReportUnFinshed> regularServiceReports = stationRegularServiceReportUnFinshedList.getStationRegularServiceReportUnFinshedList();
            logger.info("<<<<<<<<<<<<<<<<<<提交的题目数量为：" + regularServiceReports.size() + ">>>>>>>>>>>>>>>>>");
            return toSave(clientUser, regularServiceReports, stationId, reportType, reportId, startServiceTime, endServiceTime, userIds, sectionId, anchor, serviceReportId, answerOther,userType);
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResponse.errorResponseWithError("抱歉", "创建失败");
        }
    }

    private JsonResponse toSave(User user, List<StationRegularServiceReportUnFinshed> regularServiceReports,
                                Long stationId, String reportType, Long reportId,
                                Long startServiceTime, Long endServiceTime, String userIds, Long sectionId, String anchor, Long serviceReportId, String answerOther,Integer userType) {
        Station station = stationRepository.findOne(stationId);
        if (station == null) {
            return JsonResponse.errorResponseWithError("抱歉", "维修站未找到");
        }
        if (StringUtils.isEmpty(reportType)) {
            return JsonResponse.errorResponseWithError("抱歉", "报告状态错误");
        }
        StationReportTemp stationReport = null;

        //（计划报告）提交--暂存
        if (serviceReportId != null && serviceReportId != 0) {
            logger.info("<<<<<<<<<<<<<<<<<<计划的报告-提交-暂存操作>>>>>>>>>>>>>>>>>");
            StationReport completeServiceReport = stationReportRepository.findOne(serviceReportId);
            if (completeServiceReport == null) {
                return toSave(user, regularServiceReports, stationId, reportType, reportId, startServiceTime, endServiceTime, userIds, sectionId, anchor, null, answerOther,userType);
            }
            if (!completeServiceReport.getCategory().equals(Constants.SERVICE_REPORT)) {
                return JsonResponse.errorResponseWithError("抱歉", "当前报告不是常规服务报告");
            }
            QStationRegularServiceReport qStationRegularServiceReport = QStationRegularServiceReport.stationRegularServiceReport;
            BooleanBuilder builder = new BooleanBuilder();
            builder.and(qStationRegularServiceReport.deleted.eq(false));
            builder.and(qStationRegularServiceReport.enabled.eq(true));
            builder.and(qStationRegularServiceReport.stationReport.category.eq(Constants.SERVICE_REPORT));
            builder.and(qStationRegularServiceReport.stationReport.id.eq(serviceReportId));
            List<StationRegularServiceReport> stationRegularServiceReports = (List<StationRegularServiceReport>) stationRegularServiceReportRepository.findAll(builder);
            try {
                logger.info("开始删除常规报告答案,id为：" + serviceReportId);
                for (StationRegularServiceReport report : stationRegularServiceReports) {
                    stationRegularServiceReportRepository.delete(report);
                }
                logger.info("常规报告答案删除成功");
                QCustomerRegularReport qCustomerRegularReport = QCustomerRegularReport.customerRegularReport;
                BooleanBuilder b = new BooleanBuilder();
                b.and(qCustomerRegularReport.deleted.eq(false));
//                b.and(qCustomerRegularReport.enabled.eq(true));
                b.and(qCustomerRegularReport.regularReport.id.eq(serviceReportId));
                List<CustomerRegularReport> customerRegularReportList = (List<CustomerRegularReport>) customerRegularReportRepository.findAll(b);
                logger.info("开始删除常规报告与满意度报告的关联表");
                for (CustomerRegularReport report : customerRegularReportList) {
                    customerRegularReportRepository.delete(report);
                }
                logger.info("常规报告与满意度报告的关联表删除成功");
                logger.info("开始删除常规报告");
                completeServiceReport.setDeleted(true);
                completeServiceReport.setEnabled(false);
                completeServiceReport.setUserType(userType);
                stationReportRepository.save(completeServiceReport);
                logger.info("常规报告删除成功");
            } catch (Exception e) {
                e.printStackTrace();
                return JsonResponse.errorResponseWithError("抱歉", "删除原报告失败");
            }
        }
        //第一次暂存
        if (reportId == null) {
            logger.info("<<<<<<<<<<<<<<<<<<第一次暂存常规报告>>>>>>>>>>>>>>>>>");
            stationReport = new StationReportTemp();
            stationReport.setStation(station);
            stationReport.setUser(user);
            stationReport.setReportType(reportType);
            stationReport.setReportCategory(Constants.SERVICE_REPORT);
            if (StringUtils.isNotEmpty(userIds)) {
                logger.info("<<<<<<<<<<<<<<<<<<有部门跟进:" + userIds + ">>>>>>>>>>>>>>>>>");
                stationReport.setUserIds(userIds);
            }
            stationReport.setSectionId(sectionId);
            stationReport.setAnchor(anchor);
            if (StringUtils.isNotEmpty(answerOther)) {
                logger.info("<<<<<<<<<<<<<<<<<<有多选的其他服务项目:" + answerOther + ">>>>>>>>>>>>>>>>>");
                stationReport.setAnswerOther(answerOther);
            }
            if (startServiceTime != null) {
                stationReport.setStartServiceTime(new Date(startServiceTime));
            }
            if (endServiceTime != null) {
                stationReport.setEndServiceTime(new Date(endServiceTime));
            }
            logger.info("<<<<<<<<<<<<<<<<<<开始插入暂存的数据>>>>>>>>>>>>>>>>>");
            stationReport.setUserType(userType);
            stationReport = stationReportUnFinshedRepository.save(stationReport);
            for (StationRegularServiceReportUnFinshed regularServiceReportUnFinshed : regularServiceReports) {
                regularServiceReportUnFinshed.setStationReportTemp(stationReport);
                stationRegularServiceReportUnFinshedRepository.save(regularServiceReportUnFinshed);
            }
            logger.info("<<<<<<<<<<<<<<<<<<插入暂存数据完毕>>>>>>>>>>>>>>>>>");
            logger.info("<<<<<<<<<<<<<<<<<<返回暂存的ID：" + stationReport.getId() + ">>>>>>>>>>>>>>>>>");
            logger.info("***************************************************************");
            return JsonResponse.successResponseWithData(stationReport.getId());
        } else {
            //暂存--暂存
            logger.info("<<<<<<<<<<<<<<<<<<多次暂存操作>>>>>>>>>>>>>>>>>");
            QStationRegularServiceReportUnFinshed qStationRegularServiceReportUnFinshed = QStationRegularServiceReportUnFinshed.stationRegularServiceReportUnFinshed;
            BooleanBuilder builder = new BooleanBuilder();
            builder.and(qStationRegularServiceReportUnFinshed.deleted.eq(false));
            builder.and(qStationRegularServiceReportUnFinshed.enabled.eq(true));
            builder.and(qStationRegularServiceReportUnFinshed.stationReportTemp.id.eq(reportId));
            List<StationRegularServiceReportUnFinshed> regularServiceReportUnFinsheds = (List<StationRegularServiceReportUnFinshed>) stationRegularServiceReportUnFinshedRepository.findAll(builder);
            logger.info("<<<<<<<<<<<<<<<<<<开始更新暂存报告>>>>>>>>>>>>>>>>>");
            for (StationRegularServiceReportUnFinshed unFinshed : regularServiceReports) {

                for (StationRegularServiceReportUnFinshed regularServiceReportUnFinshed : regularServiceReportUnFinsheds) {

                    if (unFinshed.getQuestionId().equals(regularServiceReportUnFinshed.getQuestionId())) {

                        if (StringUtils.isNotEmpty(unFinshed.getAnswerOther())) {
                            regularServiceReportUnFinshed.setAnswerOther(unFinshed.getAnswerOther());
                        }
                        if (StringUtils.isNotEmpty(unFinshed.getAnswerId())) {
                            regularServiceReportUnFinshed.setAnswerId(unFinshed.getAnswerId());
                        }
                        if (StringUtils.isNotEmpty(unFinshed.getAnswerPhoto())) {
                            regularServiceReportUnFinshed.setAnswerPhoto(unFinshed.getAnswerPhoto());
                        }
                        stationRegularServiceReportUnFinshedRepository.save(regularServiceReportUnFinshed);
                        continue;
                    }
                }
            }
            logger.info("<<<<<<<<<<<<<<<<<<更新完毕>>>>>>>>>>>>>>>>>");
            stationReport = stationReportUnFinshedRepository.findOne(reportId);
            stationReport.setSectionId(sectionId);
            stationReport.setAnchor(anchor);
            if (StringUtils.isNotEmpty(userIds)) {
                logger.info("<<<<<<<<<<<<<<<<<<有部门跟进:" + userIds + ">>>>>>>>>>>>>>>>>");
                stationReport.setUserIds(userIds);
            }
            if (StringUtils.isNotEmpty(answerOther)) {
                logger.info("<<<<<<<<<<<<<<<<<<有多选的其他服务项目:" + answerOther + ">>>>>>>>>>>>>>>>>");
                stationReport.setAnswerOther(answerOther);
            }
            stationReport.setUserType(userType);
            stationReportUnFinshedRepository.save(stationReport);
            logger.info("<<<<<<<<<<<<<<<<<<返回暂存的ID：" + reportId + ">>>>>>>>>>>>>>>>>");
            logger.info("***************************************************************");
            return JsonResponse.successResponseWithData(reportId);
        }

    }

    @ApiOperation("获取部门待处理-改")
    @RequestMapping(value = "deparmentPending", method = RequestMethod.GET)
    public JsonResponse getDeparmentPending(@ApiIgnore Principal principal,
                                            Pageable pageable,
                                            @ApiParam("省份") @RequestParam(value = "province", required = false) String province,
                                            @ApiParam("城市") @RequestParam(value = "city", required = false) String city,
                                            @ApiParam("品牌") @RequestParam(value = "brand", required = false) String brand,
                                            @ApiParam("维修站类型") @RequestParam(value = "category", required = false) String category,
                                            @ApiParam("维修站名称") @RequestParam(value = "stationName", required = false) String stationName,
                                            @ApiParam("维修站编号") @RequestParam(value = "stationNum", required = false) String stationNum,
                                            @ApiParam("所属部门") @RequestParam(value = "department", required = false) String department,
                                            @ApiParam("该维修站是否使用我司增值服务") @RequestParam(value = "payService", required = false) String payService,
                                            @ApiParam("油漆配送时效") @RequestParam(value = "sentTime", required = false) String sentTime,
                                            @ApiParam("经销商上门服务周期") @RequestParam(value = "serviceTime", required = false) String serviceTime,
                                            @ApiParam("维修站ID") @RequestParam(value = "stationId", required = false) Long stationId,
                                            @ApiParam("服务起始时间") @RequestParam(value = "serviceStartTime", required = false) Long serviceStartTime,
                                            @ApiParam("服务结束时间") @RequestParam(value = "serviceEndTime", required = false) Long serviceEndTime,
                                            @ApiParam("起始时间") @RequestParam(value = "starTime", required = false) Long starTime,
                                            @ApiParam("结束时间") @RequestParam(value = "endTime", required = false) Long endTime,
                                            @ApiParam("填写报告人服务次数") @RequestParam(value = "serviceNum", required = false) Integer serviceNum,
                                            @ApiParam("服务项目ID") @RequestParam(value = "serviceType", required = false) String serviceType,
                                            @ApiParam("创建人员姓名") @RequestParam(value = "userName", required = false) String userName,
                                            @ApiParam("客户状态ID") @RequestParam(value = "customerStat", required = false) String customerStat,
                                            @ApiParam("客户类型ID") @RequestParam(value = "customerType", required = false) String customerType,
                                            @ApiParam("油漆品牌ID") @RequestParam(value = "paintBrand", required = false) String paintBrand,
                                            @ApiParam("品牌定位ID") @RequestParam(value = "productPosition", required = false) String productPosition,
                                            @ApiParam("是否填写满意度：true:填写，false:未填写") @RequestParam(value = "type", required = false) Boolean type,
                                            @ApiParam("标签") @RequestParam(value = "status", required = false) Integer status,
                                            @ApiParam("满意度报告分数") @RequestParam(value = "score", required = false) String score) {
//        if (principal == null) {
//            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
//        }
        User clientUser = userRepository.findByUsername("13764092002");
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        ModuleAuthority m = moduleAuthorityRepository.findByName(Constants.SERVICE_REPORT_FOLLOW_UP);
        boolean b = clientUser.getAuthorities().contains(m);
        if (b == false) {
            return JsonResponse.errorResponseWithError("抱歉", "您没有此权限:需跟进报告漆星服务常规报告审核（微信端）");
        }
        return stationServiceReportService.getDeparmentPending(pageable, province, city, brand, category, stationName, stationId, serviceStartTime, serviceEndTime,
                starTime, endTime, serviceNum, serviceType, type, score,stationNum,department,payService,sentTime,serviceTime,userName,customerStat,customerType,paintBrand,productPosition,status);
    }

    @ApiOperation("获取部门待处理-别的部门指定的")
    @RequestMapping(value = "getEditDepartmentReport", method = RequestMethod.GET)
    public JsonResponse getEditDepartmentReport(Principal principal, String province, String city, String brand, String category, String stationName,
                                                String useraName, Pageable pageable) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        return stationServiceReportService.getEditDepartmentReport(clientUser, province, city, brand, category, stationName, useraName, pageable);
    }

    //    @ApiOperation("修改跟进部门")
//    @RequestMapping(value = "editDepartmentHead", method = RequestMethod.GET)
    public JsonResponse editDepartmentHead(Principal principal,
                                           @ApiParam("报告ID") @RequestParam(value = "reportId") Long reportId,
                                           @ApiParam("指定的部门ID") @RequestParam(value = "deparmentIds") String deparmentIds) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        ModuleAuthority m = moduleAuthorityRepository.findByName(Constants.SERVICE_REPORT_FOLLOW_UP);
        boolean b = clientUser.getAuthorities().contains(m);
        if (b == false) {
            return JsonResponse.errorResponseWithError("抱歉", "您没有此权限:需跟进报告漆星服务常规报告审核");
        }
        return stationServiceReportService.editDepartmentHead(clientUser, reportId, deparmentIds);
    }

    @ApiOperation("部门确认指定负责人-改")
    @RequestMapping(value = "sureDeparmentHead", method = RequestMethod.GET)
    public JsonResponse sureDeparmentHead(Principal principal,
                                          @ApiParam("报告ID") @RequestParam(value = "reportId") Long reportId,
                                          @ApiParam("指定的部门ID") @RequestParam(value = "deparmentIds") String deparmentIds,
                                          @ApiParam("加入的备注") @RequestParam(value = "note", required = false) String note) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        ModuleAuthority m = moduleAuthorityRepository.findByName(Constants.SERVICE_REPORT_FOLLOW_UP);
        boolean b = clientUser.getAuthorities().contains(m);
        if (b == false) {
            return JsonResponse.errorResponseWithError("抱歉", "您没有此权限:需跟进报告漆星服务常规报告审核");
        }
        return stationServiceReportService.sureDeparmentHead(clientUser, reportId, deparmentIds, note);
    }

    @ApiOperation("保存部门确认指定负责人-改")
    @RequestMapping(value = "saveDeparmentHead", method = RequestMethod.GET)
    public JsonResponse saveDeparmentHead(Principal principal,
                                          @ApiParam("报告ID") @RequestParam(value = "reportId") Long reportId,
                                          @ApiParam("指定的用户ID") @RequestParam(value = "deparmentIds") String deparmentIds) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        ModuleAuthority m = moduleAuthorityRepository.findByName(Constants.SERVICE_REPORT_FOLLOW_UP);
        boolean b = clientUser.getAuthorities().contains(m);
        if (b == false) {
            return JsonResponse.errorResponseWithError("抱歉", "您没有此权限:需跟进报告漆星服务常规报告审核");
        }
        return stationServiceReportService.saveDeparmentHead(clientUser, reportId, deparmentIds);
    }


    @ApiOperation("部门获得已经确认的报告-改")
    @RequestMapping(value = "getSureDeparmentHead", method = RequestMethod.GET)
    public JsonResponse getSureDeparmentHead(@ApiIgnore Principal principal,
                                             Pageable pageable,
                                             @ApiParam("维修站ID") @RequestParam(value = "stationId", required = false) Long stationId,
                                             @ApiParam("服务起始时间") @RequestParam(value = "serviceStartTime", required = false) Long serviceStartTime,
                                             @ApiParam("服务结束时间") @RequestParam(value = "serviceEndTime", required = false) Long serviceEndTime,
                                             @ApiParam("起始时间") @RequestParam(value = "starTime", required = false) Long starTime,
                                             @ApiParam("结束时间") @RequestParam(value = "endTime", required = false) Long endTime,
                                             @ApiParam("填写报告人ID") @RequestParam(value = "userId", required = false) Long userId,
                                             @ApiParam("填写报告人服务次数") @RequestParam(value = "serviceNum", required = false) Integer serviceNum,
                                             @ApiParam("服务项目ID") @RequestParam(value = "answerId", required = false) Long answerId,
                                             @ApiParam("是否填写满意度：true:填写，false:未填写") @RequestParam(value = "type", required = false) Boolean type,
                                             @ApiParam("满意度报告分数") @RequestParam(value = "score", required = false) String score,
                                             @ApiParam("报告的处理状态") @RequestParam(value = "reportType", required = false) String reportType) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        ModuleAuthority m = moduleAuthorityRepository.findByName(Constants.SERVICE_REPORT_FOLLOW_UP);
        boolean b = clientUser.getAuthorities().contains(m);
        if (b == false) {
            return JsonResponse.errorResponseWithError("抱歉", "您没有此权限:需跟进报告漆星服务常规报告审核（微信端）");
        }
        return stationServiceReportService.getSureDeparmentHead(pageable, stationId, serviceStartTime, serviceEndTime, starTime, endTime,
                userId, serviceNum, answerId, type, score, reportType);
    }

    @ApiOperation("负责人获取被指定的报告-改")
    @RequestMapping(value = "headGetReport", method = RequestMethod.GET)
    public JsonResponse headGetReport(Principal principal,
                                      Pageable pageable,
                                      @ApiParam("省份") @RequestParam(value = "province", required = false) String province,
                                      @ApiParam("城市") @RequestParam(value = "city", required = false) String city,
                                      @ApiParam("品牌") @RequestParam(value = "brand", required = false) String brand,
                                      @ApiParam("维修站类型") @RequestParam(value = "category", required = false) String category,
                                      @ApiParam("维修站名称") @RequestParam(value = "stationName", required = false) String stationName,
                                      @ApiParam("维修站编号") @RequestParam(value = "stationNum", required = false) String stationNum,
                                      @ApiParam("所属部门") @RequestParam(value = "department", required = false) String department,
                                      @ApiParam("该维修站是否使用我司增值服务") @RequestParam(value = "payService", required = false) String payService,
                                      @ApiParam("油漆配送时效") @RequestParam(value = "sentTime", required = false) String sentTime,
                                      @ApiParam("经销商上门服务周期") @RequestParam(value = "serviceTime", required = false) String serviceTime,
                                      @ApiParam("维修站ID") @RequestParam(value = "stationId", required = false) Long stationId,
                                      @ApiParam("服务起始时间") @RequestParam(value = "serviceStartTime", required = false) Long serviceStartTime,
                                      @ApiParam("服务结束时间") @RequestParam(value = "serviceEndTime", required = false) Long serviceEndTime,
                                      @ApiParam("起始时间") @RequestParam(value = "starTime", required = false) Long starTime,
                                      @ApiParam("结束时间") @RequestParam(value = "endTime", required = false) Long endTime,
                                      @ApiParam("填写报告人服务次数") @RequestParam(value = "serviceNum", required = false) Integer serviceNum,
                                      @ApiParam("服务项目ID") @RequestParam(value = "serviceType", required = false) String serviceType,
                                      @ApiParam("创建人员姓名") @RequestParam(value = "userName", required = false) String userName,
                                      @ApiParam("客户状态ID") @RequestParam(value = "customerStat", required = false) String customerStat,
                                      @ApiParam("客户类型ID") @RequestParam(value = "customerType", required = false) String customerType,
                                      @ApiParam("油漆品牌ID") @RequestParam(value = "paintBrand", required = false) String paintBrand,
                                      @ApiParam("品牌定位ID") @RequestParam(value = "productPosition", required = false) String productPosition,
                                      @ApiParam("是否填写满意度：true:填写，false:未填写") @RequestParam(value = "type", required = false) Boolean type,
                                      @ApiParam("满意度报告分数") @RequestParam(value = "score", required = false) String score) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        ModuleAuthority m = moduleAuthorityRepository.findByName(Constants.SERVICE_REPORT_AUDIT);
        boolean b = clientUser.getAuthorities().contains(m);
        if (b == false) {
            return JsonResponse.errorResponseWithError("抱歉", "您没有此权限:需跟进报告漆星服务常规报告跟进（微信端）");
        }
        return stationServiceReportService.headGetReport(clientUser, pageable, province, city, brand, category, stationName, stationId, serviceStartTime, serviceEndTime,
                starTime, endTime, serviceNum, serviceType, type, score,stationNum,department,payService,sentTime,serviceTime,userName,customerStat,customerType,paintBrand,productPosition);
    }

    @ApiOperation("负责人处理被指定的报告-改")
    @RequestMapping(value = "headManageReport", method = RequestMethod.POST)
    public JsonResponse headManageReport(Principal principal,
                                         @ApiParam("报告ID") @RequestParam(value = "reportId") Long reportId,
                                         @ApiParam("说明") @RequestParam(value = "note") String note,
                                         @ApiParam("类型") @RequestParam(value = "type") String type,
                                         @ApiParam("部门ID") @RequestParam(value = "departmentId") Long departmentId,
                                         @ApiParam("修改的部门ID") @RequestParam(value = "departmentIds", required = false) String departmentIds) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        ModuleAuthority m = moduleAuthorityRepository.findByName(Constants.SERVICE_REPORT_AUDIT);
        boolean b = clientUser.getAuthorities().contains(m);
        if (b == false) {
            return JsonResponse.errorResponseWithError("抱歉", "您没有此权限:需跟进报告漆星服务常规报告跟进");
        }
        return stationServiceReportService.headManageReport(clientUser, reportId, note, type, departmentId, departmentIds);
    }

    @ApiOperation("管理员二次处理被指定的报告-改")
    @RequestMapping(value = "updateHeadManageReport", method = RequestMethod.POST)
    public JsonResponse updateHeadManageReport(Principal principal,
                                               @ApiParam("报告ID") @RequestParam(value = "reportId") Long reportId,
                                               @ApiParam("说明") @RequestParam(value = "note") String note,
                                               @ApiParam("类型") @RequestParam(value = "type") String type,
                                               @ApiParam("原类型") @RequestParam(value = "oldType") String oldType,
                                               @ApiParam("部门ID") @RequestParam(value = "departmentId") Long departmentId,
                                               @ApiParam("修改的部门ID") @RequestParam(value = "departmentIds", required = false) String departmentIds) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        ModuleAuthority m = moduleAuthorityRepository.findByName(Constants.SERVICE_REPORT_AUDIT);
        boolean b = clientUser.getAuthorities().contains(m);
        if (b == false) {
            return JsonResponse.errorResponseWithError("抱歉", "您没有此权限:需跟进报告漆星服务常规报告跟进");
        }
        return stationServiceReportService.updateHeadManageReport(clientUser, reportId, note, type, oldType,departmentId, departmentIds);
    }


    @ApiOperation("负责人获得已经处理的报告--改")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "页数", required = false, paramType = "query", dataType = "int"),
            @ApiImplicitParam(name = "size", value = "每页条数", required = false, paramType = "query", dataType = "int"),
    })
    @RequestMapping(value = "headGetProcessedReport", method = RequestMethod.GET)
    public JsonResponse headGetProcessedReport(Principal principal,
                                               Pageable pageable,
                                               @ApiParam("省份") @RequestParam(value = "province", required = false) String province,
                                               @ApiParam("城市") @RequestParam(value = "city", required = false) String city,
                                               @ApiParam("品牌") @RequestParam(value = "brand", required = false) String brand,
                                               @ApiParam("维修站类型") @RequestParam(value = "category", required = false) String category,
                                               @ApiParam("维修站名称") @RequestParam(value = "stationName", required = false) String stationName,
                                               @ApiParam("维修站编号") @RequestParam(value = "stationNum", required = false) String stationNum,
                                               @ApiParam("所属部门") @RequestParam(value = "department", required = false) String department,
                                               @ApiParam("该维修站是否使用我司增值服务") @RequestParam(value = "payService", required = false) String payService,
                                               @ApiParam("油漆配送时效") @RequestParam(value = "sentTime", required = false) String sentTime,
                                               @ApiParam("经销商上门服务周期") @RequestParam(value = "serviceTime", required = false) String serviceTime,
                                               @ApiParam("维修站ID") @RequestParam(value = "stationId", required = false) Long stationId,
                                               @ApiParam("服务起始时间") @RequestParam(value = "serviceStartTime", required = false) Long serviceStartTime,
                                               @ApiParam("服务结束时间") @RequestParam(value = "serviceEndTime", required = false) Long serviceEndTime,
                                               @ApiParam("起始时间") @RequestParam(value = "starTime", required = false) Long starTime,
                                               @ApiParam("结束时间") @RequestParam(value = "endTime", required = false) Long endTime,
                                               @ApiParam("填写报告人服务次数") @RequestParam(value = "serviceNum", required = false) Integer serviceNum,
                                               @ApiParam("服务项目ID") @RequestParam(value = "serviceType", required = false) String serviceType,
                                               @ApiParam("创建人员姓名") @RequestParam(value = "userName", required = false) String userName,
                                               @ApiParam("客户状态ID") @RequestParam(value = "customerStat", required = false) String customerStat,
                                               @ApiParam("客户类型ID") @RequestParam(value = "customerType", required = false) String customerType,
                                               @ApiParam("油漆品牌ID") @RequestParam(value = "paintBrand", required = false) String paintBrand,
                                               @ApiParam("品牌定位ID") @RequestParam(value = "productPosition", required = false) String productPosition,
                                               @ApiParam("标签") @RequestParam(value = "index", required = false) String index,
                                               @ApiParam("是否填写满意度：true:填写，false:未填写") @RequestParam(value = "type", required = false) Boolean type,
                                               @ApiParam("满意度报告分数") @RequestParam(value = "score", required = false) String score) {
        if (principal == null) {
            return JsonResponse.errorResponseWithError("抱歉", "invalid_token");
        }
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        ModuleAuthority m = moduleAuthorityRepository.findByName(Constants.SERVICE_REPORT_AUDIT);
        boolean b = clientUser.getAuthorities().contains(m);
        if (b == false) {
            return JsonResponse.errorResponseWithError("抱歉", "您没有此权限:需跟进报告漆星服务常规报告跟进");
        }
        return stationServiceReportService.headGetProcessedReport(clientUser, pageable, province, city, brand, category, stationName, stationId, serviceStartTime, serviceEndTime,
                starTime, endTime, serviceNum, serviceType, type, score,stationNum,department,payService,sentTime,serviceTime,userName,customerStat,customerType,paintBrand,productPosition,index);
    }

    @ApiOperation("获取暂存的服务报告--改")
    @RequestMapping(value = "getTempReport", method = RequestMethod.GET)
    public JsonResponse getTempReport(Principal principal,
                                      @ApiParam("暂存的报告ID") @RequestParam(value = "reportId", required = false) Long reportId) {
        User clientUser = userRepository.findByUsername(principal.getName());
        if (clientUser == null) {
            return JsonResponse.errorResponseWithError("500", "未找到此用户");
        }
        return stationServiceReportService.getTempReport(reportId);
    }


    String getAnswerString(String answerIds) {
        List<String> answers = new ArrayList<>();
        List<Long> answerIdArray = ArrayStringUtil.getStringIds(answerIds);
        for (Long answerId : answerIdArray) {
            QuestionAnswerOption questionAnswerOption = questionAnswerOptionRepository.findOne(answerId);
            answers.add(questionAnswerOption.getName());
        }
        return StringUtils.join(answers, ",");
    }

    String filterAnswerOther(String answerOther) {
        try {
            Long currentMin = Long.parseLong(answerOther);
            if (currentMin > 1000000) {
                Date date = new Date(currentMin);
                if (ValidateUtil.isValidMobileNo(answerOther)) {
                    return DateUtil.formatDate(date, Constants.DATE_FORMAT);
                } else {
                    return AnswerOtherUtil.getOtherString(answerOther);
                }
            } else {
                return AnswerOtherUtil.getOtherString(answerOther);
            }
        } catch (Exception e) {
            return AnswerOtherUtil.getOtherString(answerOther);
        }
    }

    //    @ApiOperation("发送苑辉的短信")
//    @RequestMapping(value = "sendKongSms", method = RequestMethod.GET)
    public JsonResponse sendKongSms() {
        Long[] ids = new Long[1];
        ids[0] = 12L;
        StringBuffer telephone = new StringBuffer("");
        Map<String, Integer> telMap = new HashMap<>();
        for (Long id : ids) {
            QUserProfile qUserProfile = QUserProfile.userProfile;
            BooleanBuilder builder = new BooleanBuilder();
            builder.and(qUserProfile.deleted.eq(false));
            builder.and(qUserProfile.enabled.eq(true));
            builder.and(qUserProfile.departmentList.any().id.eq(id));
            List<UserProfile> userProfileList = (List<UserProfile>) userProfileRepository.findAll(builder);
            for (UserProfile userProfile : userProfileList) {
                if (telMap.containsKey(userProfile.getTelephone())) {
                    continue;
                } else {
                    telMap.put(userProfile.getTelephone(), 1);
                }
            }
        }
        for (Map.Entry<String, Integer> entry : telMap.entrySet()) {
            telephone.append(entry.getKey() + ",");
        }
        try {
            logger.info("---------------------------开始发送短息----------------------");
            aliSmsProvider.sendMsg_24(telephone.toString(), "苑辉", "贵州华通华福汽车销售服务有限公司",
                    "漆星服务", "销售部-西南");
            logger.info("---------------------------发送完成----------------------");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return JsonResponse.successResponse();
    }


}
